import logging, sys, cmd

import grpc
import nexus_pb2
import nexus_pb2_grpc


def run():
	with grpc.insecure_channel('localhost:6666') as channel:
		stup = nexus_pb2_grpc.NexusServiceStub(channel)
		response = stup.Info(nexus_pb2.Device(id=sys.argv[1],name=sys.argv[2]))
 
channel = grpc.insecure_channel('localhost:6666')
stub = nexus_pb2_grpc.NexusServiceStub(channel)
  
class MyShell(cmd.Cmd):  
    prompt = 'nmshell> '
  
    def do_greet(self, arg):
        stub.AddDevice(nexus_pb2.Device(name=arg))
        print('Hello,', arg)  
  
    def do_add_route(self, arg):
        stub.AddRoute(nexus_pb2.Route(addr='10.0.0.0'))
        print('Hello,', arg)  
  
    def do_quit(self, arg):  
        return True  
  
if __name__ == '__main__':  
  logging.basicConfig()
  MyShell().cmdloop()